package com.gxa.admin.recycling.service.impl;

import com.gxa.admin.recycling.mapper.CommunityManageMapper;
import com.gxa.admin.recycling.service.CommunityManageService;
import com.gxa.core.recycling.pojo.CommunityManage;
import com.gxa.core.recycling.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;


@Service("communityManageService")
public class CommunityManageServiceImpl extends BaseServiceImpl<CommunityManage> implements CommunityManageService {
    @Autowired
    CommunityManageMapper communityManageMapper;
    @Override
    public List<Map> distributionCommunity(String proviences, String name, Boolean isDistribution, Integer page, Integer size) {
        return communityManageMapper.distributionCommunity(proviences, name, isDistribution, (page-1)*size, size);
    }

    @Override
    public Map distributionById(Long id) {
        return communityManageMapper.distributionById(id);
    }

    @Override
    public List<Map> recyclerList() {
        return communityManageMapper.recyclerList();
    }

    @Override
    public void deleteDistribution(Long communityId, Long recyclerId) {
        communityManageMapper.deleteDistribution(communityId, recyclerId);
    }

    @Override
    public void addDistributionCommunity(Long communityId, Long recyclerId) {
        communityManageMapper.addDistributionCommunity(communityId, recyclerId);
    }

    @Override
    public List<CommunityManage> findCommunityManageByProvinces(String provinces) {

        Example example=new Example(CommunityManage.class);

        Example.Criteria criteria = example.createCriteria();

        criteria.andLike("provinces","%"+provinces+"%");

        List<CommunityManage> communityManages = communityManageMapper.selectByExample(example);

        return communityManages;


    }
}
